#!/bin/bash
# Program:
#        Let user input a filename, the program will search the filename
#        1) exist? 2) file/directory? 3) file permissions
# History:
# 2010/06/06        xuzhi       First Release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

read -p "Please input a filename: " filename
test -e $filename || (echo "$filename does not exist" && exit 0)

test -f $filename && echo -e "$filename is regular file" || \
(test -d $filename && echo -e "$filename is directory" || \
echo -e "$filename is other file")

test -r $filename && echo -e "can read" || echo -e "can not read"
test -w $filename && echo -e "can write" || echo -e "can not write "
test -x $filename && echo -e "can exec" || echo -e "can not exec "
test -u $filename && echo -e "can suid" || echo -e "can not suid "
test -g $filename && echo -e "can sgid" || echo -e "can not sgid "
test -k $filename && echo -e "can sbit" || echo -e "can not sbit "
test ! -s $filename && echo -e "is blank" || echo -e "is not blank "
